﻿#pragma execution_character_set("utf-8")
#include "base_grade_widget.h"
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSpinBox>
#include <QLineEdit>
#include <QLabel>
#include <QFileDialog>
BaseGradeWidget::BaseGradeWidget(QWidget *parent)
    : QWidget(parent)
    , m_layoutNum(new QHBoxLayout())
    , m_layoutMain(new QVBoxLayout())
    , m_btn(new QPushButton("生成题目",this))
    , m_btnSavevFile(new QPushButton(tr("选择保存文件路径")))
    , m_edtSaveFileName(new QLineEdit())
    , m_layoutSaveFile(new QHBoxLayout())
    , m_labNum(new QLabel(tr("题目数量：")))
    , m_SpinBoxNum(new QSpinBox)
{

}

void BaseGradeWidget::slotClickBtn()
{
    soltDoWork();
}

void BaseGradeWidget::slotClickSaveBtn()
{
    QString file_path = QFileDialog::getSaveFileName(this,tr("save as "),"",tr("*.txt"));
    m_edtSaveFileName->setText(file_path);
}

void BaseGradeWidget::initUI()
{
    m_SpinBoxNum->setMaximum(1000);
    m_SpinBoxNum->setValue(100);
    m_layoutSaveFile->addWidget(m_btnSavevFile);
    m_layoutSaveFile->addWidget(m_edtSaveFileName);
    m_layoutNum->addWidget(m_labNum);
    m_layoutNum->addWidget(m_SpinBoxNum);
    m_layoutMain->addLayout(m_layoutSaveFile);
    m_layoutMain->addLayout(m_layoutNum);
    m_layoutMain->addWidget(m_btn);

    m_layoutMain->addStretch();
    setLayout(m_layoutMain);
}

void BaseGradeWidget::initConnect()
{
    connect(m_btn,&QPushButton::clicked,this,&BaseGradeWidget::slotClickBtn);
    connect(m_btnSavevFile,&QPushButton::clicked,this,&BaseGradeWidget::slotClickSaveBtn);
 }
